package cn.demomaster.quickdb_sample;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;
import android.text.TextUtils;
import android.util.Log;

import cn.demomaster.quickdb.QuickDb;
import cn.demomaster.quickdb.listener.UpgradeInterface;
import cn.demomaster.quickdb_sample.model.Member;
import cn.demomaster.quickdb_sample.model.Order;

public class MyApp extends Application implements UpgradeInterface {
    private static final String TAG = "MyApp";
    public QuickDb dbHelper;
    @Override
    public void onCreate() {
        super.onCreate();
    }

    private void creatTable() {
        Log.i(TAG,"创建表");
        try {
            getDbHelper().createTable(Member.class);
            getDbHelper().createTable(Order.class);
            getDbHelper().createTable(Order.class);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public QuickDb getDbHelper() {
        if (dbHelper == null) {
            String dbpath = "quick_db.db";

            if (!TextUtils.isEmpty(dbpath)) {
                dbHelper = new QuickDb(this, dbpath, null, 11, this);
                // dbHelper = new QuickDb(this, dbpath, null, 7, this);
            }
        }
        return dbHelper;
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
